"""XApiTestServer URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url
from django.urls import path
from django.contrib import admin
from django.views.generic import RedirectView

from XApiTestServer.views import load
from XApiTestServer.views import user
from XApiTestServer.views import stat
from XApiTestServer.views import project
from XApiTestServer.views import module
from XApiTestServer.views import config
from XApiTestServer.views import auth
from XApiTestServer.views import case
from XApiTestServer.views import suite
from XApiTestServer.views import report
from XApiTestServer.views import schedule
from XApiTestServer.views import file
from XApiTestServer.views.run import run_test
from XApiTestServer.views.logs import show_logs
from XApiTestServer.views.debugtalk import getDebugtalk
from XApiTestServer.views import mock


urlpatterns = [
    url(r'register/$', user.UserViewSet.as_view({'post': 'create'})),
    url(r'login/$', user.login),
    url(r'logout/$', user.logout),
    url(r'getpassword/$', user.get_password),
    url(r'updatepassword/$', user.update_password),
    url(r'user/(?P<pk>\d+)/$', user.UserViewSet.as_view({'delete': 'destroy',
                                                              'put': 'update', 'get': 'retrieve'})),

    url(r'dashboard/$', stat.dashboard_stat),

    url(r'load_json/$', load.load_json),

    url(r'project/$', project.ProjectViewSet.as_view({'get': 'list', 'post': 'create'})),
    url(r'project/(?P<pk>\d+)/$', project.ProjectViewSet.as_view({'delete': 'destroy',
                                                                      'put': 'update', 'get': 'retrieve'})),
    url(r'project_sum/$', project.ProjectSumViewSet.as_view({'get': 'list'})),

    url(r'module/$', module.ModuleViewSet.as_view({'get': 'list', 'post': 'create'})),
    url(r'module/(?P<pk>\d+)/$', module.ModuleViewSet.as_view({'delete': 'destroy',
                                                                          'put': 'update', 'get': 'retrieve'})),
    url(r'module_sum/$', module.ModuleSumViewSet.as_view({'get': 'list'})),

    url(r'config/$', config.ConfigViewSet.as_view({'get': 'list', 'post': 'create'})),
    url(r'config/(?P<pk>\d+)/$', config.ConfigViewSet.as_view({'delete': 'destroy',
                                                                       'put': 'update', 'get': 'retrieve'})),
    url(r'config_sum/$', config.ConfigSumViewSet.as_view({'get': 'list'})),

    url(r'testauth/$', auth.testauth),
    url(r'auth/$', auth.AuthViewSet.as_view({'get': 'list', 'post': 'create'})),
    url(r'auth/(?P<pk>\d+)/$', auth.AuthViewSet.as_view({'delete': 'destroy',
                                                                 'put': 'update', 'get': 'retrieve'})),
    url(r'auth_sum/$', auth.AuthSumViewSet.as_view({'get': 'list'})),

    url(r'case/$', case.CaseViewSet.as_view({'get': 'list', 'post': 'create'})),
    url(r'case/(?P<pk>\d+)/$', case.CaseViewSet.as_view({'delete': 'destroy',
                                                                 'put': 'update', 'get': 'retrieve'})),
    url(r'case_sum/$', case.CaseSumViewSet.as_view({'get': 'list'})),

    url(r'suite/$', suite.SuiteViewSet.as_view({'get': 'list', 'post': 'create'})),
    url(r'suite/(?P<pk>\d+)/$', suite.SuiteViewSet.as_view({'delete': 'destroy',
                                                                 'put': 'update', 'get': 'retrieve'})),
    url(r'suite_sum/$', suite.SuiteSumViewSet.as_view({'get': 'list'})),

    url(r'run_test/$', run_test),

    url(r'logs/$', show_logs),

    url(r'debugtalk/$', getDebugtalk),

    url(r'report/$', report.ReportViewSet.as_view({'get': 'list', 'post': 'create'})),
    url(r'report/(?P<pk>\d+)/$', report.ReportViewSet.as_view({'delete': 'destroy',
                                                                 'get': 'retrieve'})),
    url(r'^reportdownload/(?P<pk>\d+)/$', report.ReportViewSet.as_view({'get': 'reportdownload'})),

    url(r'file/$', file.FileViewSet.as_view({'get': 'list', 'post': 'create'})),
    url(r'file/(?P<pk>\d+)/$', file.FileViewSet.as_view({'delete': 'destroy',
                                                                 'put': 'update', 'get': 'retrieve'})),

    url(r'schedule/$', schedule.ScheduleTaskView.as_view({'get': 'list', 'post': 'create'})),
    url(r'schedule/(?P<pk>\d+)/$', schedule.ScheduleTaskView.as_view({'delete': 'destroy',
                                                         'put': 'update', 'get': 'retrieve'})),

    url(r'testmock/$', mock.testmock),
    url(r'mock_conf/$', mock.MockViewSet.as_view({'get': 'list', 'post': 'create'})),
    url(r'mock_conf/(?P<pk>\d+)/$', mock.MockViewSet.as_view({'delete': 'destroy',
                                                               'put': 'update', 'get': 'retrieve'})),
]
